package com.example.emailcraft;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;

import java.util.Collections;

public class CodeGeneratorForGDBC {
    public static void main(String[] args) {
        FastAutoGenerator.create(new DataSourceConfig.Builder(
                        "jdbc:mysql://101.34.242.206:3306/email_sql?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC",
                        "email_sql",
                        "Ph5k6pKwNT5CZszP"))
                .globalConfig(builder -> {
                    builder.author("scj") // 设置作者
                            .outputDir(System.getProperty("user.dir") + "/src/main/java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.example.emailcraft") // 设置父包名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, System.getProperty("user.dir") + "/src/main/resources/mapper/xml"));
                })
                .strategyConfig(builder -> {
                    builder
                            // 设置需要生成的表名（根据你的实际表名修改）
                            .addInclude("users", "template_categories", "system_templates", "user_templates", "permissions", "roles", "role_permissions", "user_roles")
                            .entityBuilder()
                            .naming(NamingStrategy.underline_to_camel)
                            .enableLombok()
                            .controllerBuilder()
                            .enableRestStyle()
                            .mapperBuilder()
                            .enableBaseResultMap()
                            .enableBaseColumnList();
                })
                .templateEngine(new VelocityTemplateEngine())
                .execute();
    }
}






